package com.rt.gptnext.common.bean;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import jakarta.persistence.Column;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;

/**
 * @author gaoyiyang
 **/
@Getter
@Setter
@MappedSuperclass
public abstract class BaseEntity<T extends Model<?> & IBean<?>> extends Model<T> implements IBean<T> {

    @Id
    @TableId(value = "id", type = ASSIGN_ID)
    protected Long id;

    @Column(columnDefinition = "datetime")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected Date createTime;

    @Column(columnDefinition = "datetime")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected Date updateTime;

}
